<?php 
namespace Admin\Model;
use Think\Model;
/*
	上传素材
*/
class UploadMaterialModel extends Model {
	
	protected $tableName = 'user_upload_material'; 
	
	//总数
	public function upload_material_total(){
		$total = M('UserUploadMaterial')->where('is_pass != -2 and is_pass != -1')->count('id');
		return $total;
	}
	
	//修改
	public function upload_material_save($id,$data){
		$rc = M('UserUploadMaterial')->where('id = %d',$id)->save($data);
		return $rc;
	}
	
	//查询单条
	public function upload_material_find($id){
		$rc = M('UserUploadMaterial')->where('id = %d and is_pass != -2',$id)->find();
		return $rc;
	}
	
	//多条
	public function upload_material_list($where = '',$limit='0,10'){
		$rc = M('UserUploadMaterial')->alias('uum')
									 ->join('__USER__ as u on uum.uid = u.id')
									 ->where('uum.is_pass != -2 '.$where.'')
									 ->order('uum.id desc')
									 ->limit($limit)
									 ->field('uum.*,u.mobile')
									 ->select();
		return $rc;
	}
	
	//后台数据添加
	public function admin_materia_add($data){
		
		$rc = M('UserUploadMaterialLog')->add($data);
		return $rc;
	}
	
	
}
